<template>
	<view class="box">
		<page-meta>
			<navigation-bar :title="detailData.name"></navigation-bar>
		</page-meta>
		<view class="inner">
			<view>
				<image mode="scaleToFill" :src="detailData.cover.path"></image>
			</view>
			<view>
				<view>{{detailData.name}}</view>
				<text>作者：{{detailData.author}}</text>
				<text>出版社：{{detailData.press}}</text>
				<text>更新时间：{{detailData.created_at}}</text>
			</view>
		</view>
		<view class="brief">
			<view>简介</view>
			<view>{{detailData.introduce}}</view>
		</view>
		<u-button type="primary" @click="ydClick">立即阅读</u-button>
	</view>
</template>

<script>
	import {
		literatureDetail
	} from '../../api/api';
	import {
		getDate
	} from '../../util';
	export default {
		data() {
			return {
				id: "",
				detailData: {},
			};
		},
		onLoad(e) {
			this.id = e.id;
			this.getData();
		},
		methods: {
			getData() {
				uni.showLoading({
					title: "加载中……"
				});
				literatureDetail(this.id).then(r => {
					uni.hideLoading();
					this.detailData = {
						...r.data,
						created_at: getDate(r.data.created_at),

					};
				});
			},
			ydClick() {
				uni.showModal({
					title: "阅读",
					content: "效果和wx小程序一致，就不重新写了，一致"
				})
			}
		}
	}
</script>

<style lang="scss" scoped>
	.box {
		padding: 10rpx;
	}

	.inner {
		width: 100%;
		display: flex;
		justify-content: space-between;
		color: #aaa;
		font-size: 24rpx;
		background: #fff;
		align-items: center;

		>view:first-of-type {
			flex: 1;
			margin-right: 20rpx;

			>image {
				width: 212rpx;
				height: 266rpx;
			}
		}

		>view:last-of-type {
			flex: 3;

			>view:first-of-type {
				color: #111;
				font-size: 36rpx;
				font-weight: 900;
				overflow: hidden;
				text-overflow: ellipsis;
				white-space: nowrap;
			}

			text {
				display: block;
				margin-top: 20rpx;
			}
		}
	}

	.brief {
		width: 100%;
		margin-top: 20rpx;
		margin-bottom: 10rpx;

		>view:first-of-type {
			font-size: 28rpx;
			font-weight: 700;
			border-left: 12rpx solid #1677ff;
			padding-left: 12rpx;
			line-height: 26rpx;
		}

		>view:last-of-type {
			font-size: 24rpx;
			margin-top: 10rpx;
			color: #111;
		}
	}
</style>
